<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Statement" %><%--
  Created by IntelliJ IDEA.
  User: 29904
  Date: 2024/10/9
  Time: 15:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>排序查询</title>
    <%! ResultSet rs;%>
<%
        String dbName = "studb";
        String userName = "root";
        String userPasswd = "123456";
        String url = "jdbc:mysql://localhost/"+dbName+"?user"+userName+"&password="+userPasswd;
        Class.forName("com.mysql.jdbc.Driver");
        Connection conn = DriverManager.getConnection(url);
        Statement statement = conn.createStatement();
        String sql = "select*from student ORDER BY stuclass DESC,number ASC";
        rs = statement.executeQuery(sql);
%>
<body>
<table border="1">
    <th colspan="4" style="font-size: x-large;alignment: center">学生信息表</th>
    <tr style="text-align: center">
        <td>学号</td>
        <td>姓名</td>
        <td>出生日期</td>
        <td>所在班级</td>
    </tr>
    <% while(rs.next()){%>
        <tr style="text-align:center">
            <tb><%=rs.getString(1)%></tb>
            <tb><%=rs.getString(2)%></tb>
            <tb><%=rs.getString("birthday")%></tb>
            <tb><%=rs.getString("stuclass")%></tb>
        </tr>
    <%}%>
    <%
        rs.close();
        statement.close();
        conn.close();
    %>
</table>
</body>
</html>
